<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>{:lang('admin/index/login/title')}</title>
    <link rel="stylesheet" href="{:MAC_BASE_PATH}/static/layui/css/layui.css?v=1024">
    <link rel="stylesheet" href="{:MAC_BASE_PATH}/static/css/admin_style.css?v=1024">

    <link rel="stylesheet" href="{:MAC_BASE_PATH}/static/pear/css/pear.css?v=1024">
    <link rel="stylesheet" href="{:MAC_BASE_PATH}/static/admin/css/load.css?v=1024">
    <link rel="stylesheet" href="{:MAC_BASE_PATH}/static/admin/css/admin.css?v=1024">

</head>
<body class="login-body body">
<div class="login-head">
    <a href="//www.maccms.pro/">{:lang('admin/index/login/tip_welcome')}</a>
</div>
<div class="login-box">
    <form class="layui-form " method="post" action="">
        <div class="layui-form-item h1">
            <h3>{:lang('admin/index/login/tip_sys')}</h3>
            <select class="lang-select" name="lang" lay-filter="lang" style="width: 40px;">
                <option value="">{:lang('install/select_lang')}</option>
                {foreach name="langs" key="key" item="vo"}
                <option value="{$vo}" {if condition="$lang eq $vo"}selected {/if}>{$vo}</option>
                {/foreach}
            </select>
        </div>
        <div class="layui-form-item account">
            <img class="icon" src="{:MAC_BASE_PATH}/static/images/other/login-user.png"/>
            <div class="layui-input-block">
                <input type="text" name="admin_name" class="layui-input" lay-verify="admin_name" placeholder="{:lang('admin/index/login/verify_no')}" autocomplete="on" maxlength="20"/>
            </div>
        </div>
        <div class="layui-form-item pass">
            <img class="icon" src="{:MAC_BASE_PATH}/static/images/other/login-pass.png"/>
            <div class="layui-input-block">
                <input type="password" name="admin_pwd" class="layui-input" lay-verify="admin_pwd" placeholder="{:lang('admin/index/login/verify_pass')}" maxlength="20"/>
            </div>
        </div>

        {if condition="$GLOBALS['config']['app']['admin_login_verify'] neq '0'"}
        <div class="layui-form-item verify">
            <img class="icon" src="{:MAC_BASE_PATH}/static/images/other/login-check.png"/>
            <div class="layui-input-block">
                <input type="number" name="verify" class="layui-input" lay-verify="verify" placeholder="{:lang('admin/index/login/verify_verify')}" maxlength="4"  max="9999"/>
                <img id="verify_img" src="{$verify_img_src}" onclick="this.src = this.src+'?'">
            </div>
        </div>
        {/if}
        <button type="button" class="pear-btn pear-btn-primary pear-btn-md btn-submit" lay-submit="" lay-filter="sub">{:lang('admin/index/login/btn_submit')}</button>
    </form>
    <div class="copyright">
        {:lang('maccms_copyright')}
    </div>
    <div class="title">{:lang('admin/index/login/tip_declare')}</div>
    <div class="desc">{:lang('admin/index/login/tip_declare_txt')}</div>

</div>

<div class="circle"></div>

<script type="text/javascript" src="{:MAC_BASE_PATH}/static/layui/layui.js"></script>
<script type="text/javascript" src="{:MAC_BASE_PATH}/static/js/admin_common.js?{:system_version()}"></script>
<script type="text/javascript">
    layui.use(['form', 'layer'], function () {
        // 操作对象
        var form = layui.form
                , layer = layui.layer
                , $ = layui.jquery;

        // 验证
        form.verify({
            admin_name: function (value) {
                if (value == "") {
                    return "{:lang('admin/index/login/verify_no')}";
                }
            },
            admin_pwd: function (value) {
                if (value == "") {
                    return "{:lang('admin/index/login/verify_pass')}";
                }
            },
            verify: function (value) {
                if (value == "") {
                    return "{:lang('admin/index/login/verify_verify')}";
                }
            }
        });

        // 提交监听
        form.on('submit(sub)', function (data) {
            layer.msg("{:lang('wait_submit')}",{time:500000});
            $.post("{:url('index/login')}",data.field,function(r){
                if(r.code == 1){
                    location.href = "{:url('index/index')}";
                }
                else{
                    layer.msg(r.msg,{time:1800});
                    $('#verify_img').click();
                }
            });
            return false;
        });
        form.on('select(lang)',function(data){
            if(data.value !='') {
                location.href = "{:url('index/login')}?lang=" + (data.value);
            }
        });

        $("input[name='admin_name']").bind('keypress',function(event){
            if(event.keyCode == "13") {
                if($("input[name='admin_name']").val()!=''){
                    $("input[name='admin_pwd']").focus();
                }
            }
        });

        $("input[name='admin_pwd']").bind('keypress',function(event){
            if(event.keyCode == "13") {
                if($("input[name='admin_pwd']").val()!=''){
                    $("input[name='verify']").focus();
                }
            }
        });

        $("input[name='verify']").bind('keypress',function(event){
            if(event.keyCode == "13") {
                if($("input[name='verify']").val()!=''){
                    $('.btn-submit').click();
                }
            }
        });
        // iframe中跳转到登录页，外层框架要刷新
        if(window.parent){
            if(window.parent.parent){
                window.parent.parent.postMessage('reload');
            }else{
                window.parent.postMessage('reload');
            }
        }
    });

</script>
</body>
</html>